package com.ncr.travel.appmgr.client.ui.table;

import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;

/**
 * A simple extension of FlexTable that loads its data cells from a TableModel object
 * 
 * @author ma250087
 */
public class LiveFlexTable extends FlexTable {
	public LiveFlexTable(TableModel<?> model) {
	    if(model.isShowColumnDescriptorHeader()) {
    		for (int i = 0; i < model.getColumnCount(); ++i) {
    			System.out.println("[0, " + i + "] Heading = " + model.getColumnDescriptor(i).getHeading());
    			setWidget(0, i, new Label(model.getColumnDescriptor(i).getHeading()));
    		}
	    }
		for (int i = 0; i < model.getRowCount(); ++i) {
			for (int j = 0; j < model.getColumnCount(); ++j) {
				System.out.println("[" + (i + 1) + ", " + j + "] Cell = " + model.getCell(i, j));
				setWidget(i + 1, j, model.getCell(i, j));
			}
		}
	}
}
